package com.springmvc.netty;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;

import com.springmvc.netty.server.websocket.WebSocketServer;

@Repository
public class StartServer {

	private static final Logger	LOGGER			= LoggerFactory.getLogger(StartServer.class);

	WebSocketServer				websocketServer	= new WebSocketServer();

	ThreadServer				nettyServer		= new ThreadServer(8989, websocketServer);

	// 程序初始方法入口注解，提示spring这个程序先执行这里
	@PostConstruct
	public void serverStart1() {
		LOGGER.info("@PostConstruct......");
		nettyServer.start();
	}

	@PreDestroy
	public void serverStop1() {
		LOGGER.info("@PreDestroy.........");
		nettyServer.interrupt();

	}
}
